import { Progress } from 'antd';
export default class Main extends React.Component{
	constructor(props) {
		super(props);
	}
	
	componentWillReceiveProps(nextProps){
		const {datas = {}} = nextProps;
		const listB = datas.listB||[];
		const fileuploadphrasedom = $(this.refs.wfRemarkProgress.parentElement).parent().parent();
		if(listB.length > 0){
			fileuploadphrasedom.css('top','-40px');
			fileuploadphrasedom.find('.file-content-block').hide();
		}else{
			const _datas  = this.props.datas||[];
			const _listB  = _datas.listB||[];
			if(_listB.length > 0 && listB.length === 0 ){
				fileuploadphrasedom.find('.file-content-block').show();
				let num  = fileuploadphrasedom.find('li').length;
				num  = num  > 4 ? 4 : num;
				fileuploadphrasedom.css('top',`${-(28 * num + 57)}px`);
			}
		}
	}
	
	render(){
		const {datas = {}} = this.props;
		const listB = datas.listB||[]
//		const listB = [];
//		listB.push({name:'正式系统升级KB170300-KB8100170502交叉文件列表.xlsx',progress:100,showProgress:true});
		let top  =  listB.length > 1 ? -((listB.length - 1) * 34 + 5) : -5;
		
		return (
			<div className="wf_upload_progress" style={{display:listB.length > 0 ? "block":"none",top:top}} ref="wfRemarkProgress">
				{
					listB.map((d,ecindex) => {
						const { name, id, progress, showProgress, error, progressStatus } = d;
						let status = error && progressStatus ? {status: progressStatus} : {};
						return (
							<div className='wea-upload-list-item'>
								<div className='wea-upload-list-item-file'>
									{name}
								</div>
								{showProgress && <Progress ecId={`${this && this.props && this.props.ecId || ''}_Progress@tu7m1h@${ecindex}`} style={{width:'100%',height:'18px',lineHeight:'18px',display:'block'}} showInfo={false} percent={progress} strokeWidth={3} {...status}/>}
							</div>
						)
					})
				}
			</div>
		)
	}
}
